using Boo.Lang;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

[Serializable]
public class musicplayer : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	internal sealed class _0024wait_0024422 : GenericGenerator<WaitForSeconds>
	{
		internal musicplayer _0024self__0024424;

		public _0024wait_0024422(musicplayer self_)
		{
			_0024self__0024424 = self_;
		}

		public override IEnumerator<WaitForSeconds> GetEnumerator()
		{
			return new _0024(_0024self__0024424);
		}
	}

	public AudioClip[] songs;

	public int currentsong;

	public bool playnow;

	public int state;

	public musicplayer()
	{
		state = 1;
	}

	public void Awake()
	{
		UnityEngine.Object.DontDestroyOnLoad(gameObject);
	}

	public void Start()
	{
		if (state == 1)
		{
			RandomizeBuiltinArray();
			GetComponent<AudioSource>().volume = PlayerPrefs.GetFloat("MusicVolume");
			GetComponent<AudioSource>().clip = songs[currentsong];
			if (PlayerPrefs.GetInt("Music") == 1)
			{
				StartCoroutine(wait());
				GetComponent<AudioSource>().Play();
				state = 0;
			}
		}
	}

	public void RandomizeBuiltinArray()
	{
		for (int num = songs.Length - 1; num > 0; num--)
		{
			int num2 = UnityEngine.Random.Range(0, 0);
			AudioClip audioClip = songs[num];
			songs[num] = songs[num2];
			songs[num2] = audioClip;
		}
		currentsong = 0;
	}

	public void music()
	{
		nextsong();
	}

	public IEnumerator wait()
	{
		return new _0024wait_0024422(this).GetEnumerator();
	}

	public void nextsong()
	{
		if (currentsong < 0)
		{
			currentsong++;
		}
		if (currentsong == 0)
		{
			RandomizeBuiltinArray();
		}
		GetComponent<AudioSource>().clip = songs[currentsong];
		StartCoroutine(wait());
		GetComponent<AudioSource>().Play();
		playnow = false;
	}

	public void Main()
	{
	}
}
